package university;

import static org.junit.Assert.*;
import static university.RegistrationConfigurationUtil.*;

import numbers.INumberGenerator;
import numbers.NumberGenerator;

import org.junit.Before;
import org.junit.Test;

public class A1X04_RegistrarsOfficeTest {

	/*
	 * Feel free to write a test that checks the behavior of the
	 * RegistrarsOffice. What kind of interaction sequences would you like to
	 * test? Does the class satisfy your expectations?
	 */

	Student student1;
	Student student2;
	Student student3;

	// Will be executed before each test run
	@Before
	public void createStudents() {
		student1 = new Student("Glenn Dwiyatcita");
		student2 = new Student("Georgios Kotsios");
		student3 = new Student("Volkan Guenal");
	}
	
	@Test
	public void customTest() {
		RegistrarsOffice registrar = new RegistrarsOffice("RWTH Aachen University");
		INumberGenerator generator = new NumberGenerator();
		generator.setNextNumber(314311);
		registrar.setMatriculationNumberGenerator(generator);
		registrar.matriculate(student1);
		assertEquals(314311, student1.getMatriculationNumber());
		assertTrue(student1.isEnrolled());
		
		configureToGetHighMatriculationNumbers(registrar);
		registrar.matriculate(student2);
		assertEquals(10100, student2.getMatriculationNumber());
		assertTrue(student2.isEnrolled());
		
		configureToCareForSuperstition(registrar);
		registrar.matriculate(student3);
		assertEquals(1010, student3.getMatriculationNumber());
		assertTrue(student3.isEnrolled());
		
		registrar.exmatriculate(student2);
		assertEquals(-1, student2.getMatriculationNumber());
		assertFalse(student2.isEnrolled());
		
		registrar.matriculate(student2);
		assertEquals(1011, student2.getMatriculationNumber());
		assertTrue(student2.isEnrolled());
	}
}
